package cn.jx.asc.common.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * @author lhg
 */
@Component
@ConfigurationProperties(prefix = "spring.datasource")
public class DataBaseConfig {
    private static String username;
    private static String password;
    private static String url;

    public static String getUsername() {
        return username;
    }

    public  void setUsername(String username) {
        DataBaseConfig.username = username;
    }

    public static String getPassword() {
        return password;
    }

    public  void setPassword(String password) {
        DataBaseConfig.password = password;
    }

    public static String getUrl() {
        return url;
    }

    public  void setUrl(String url) {
        DataBaseConfig.url = url;
    }

    public static String getIp(){
        final String s1 = getUrl().split("/")[2];
        return s1.split(":")[0];
    }

    public static String getDataBase(){
        final String s1 = getUrl().split("/")[3];
        return s1.split("\\?")[0];
    }
}
